# -*- coding: utf-8 -*-
# @Time    : 2021/8/10 8:36
# @Version : V1.0.0
# @Author  : liumingming
# @FileName: mesh.py
# @Company ：http://www.iqi-inc.com/
import sys
import time

import AiDragonfly



maclist=['00:3D:5C:00:20:AA','01:08:15:00:1F:AB']
# maclist = ['00:3D:5C:00:20:AA']
# maclist = ['B86A888D-69AC-49DA-95E4-E519BC0B7ED7','4E838810-4338-4E42-81FC-7AEFB3BACDE4']
# maclist=['01:08:15:00:1F:AB']
# namelist=["OneBot_XL_M","OneBot_St_M"]
# namelist=["OneBot_BL_M"]

def user_rev_handle(num,data):
    print(data)


# 调试蓝牙，请不要使用蓝牙鼠标，否则同时使用，会导致异常
def bluetooth_disconnect_handle(res):
    print('disconnect ')



if __name__ == '__main__':
    AiDragonfly.User_Receive_Callback_Register(user_rev_handle)
    AiDragonfly.start(app_reset="",namelist=[],disconnect_callback=bluetooth_disconnect_handle)
    time.sleep(1)
    AiDragonfly.Mesh.Connect_Init()

    while True:
        try :
            AiDragonfly.Mesh.Motor_Ctrl([-30, 30,30])
            time.sleep(3)
            AiDragonfly.Mesh.Motor_Ctrl([30, -30,30])
            time.sleep(3)
        except:
            AiDragonfly.Mesh.Motor_Ctrl([0, 0])
            time.sleep(1)
            sys.exit("err exit")

        


